Skip to content

fix: INTL0101 code fix NotImplementedException for non-class declaration types#411

Merged
BenjaminMichaelis merged 1 commit intomainfrom
bmichaelis/updateFix
Mar 16, 2026
Merged

fix: INTL0101 code fix NotImplementedException for non-class declaration types#411
BenjaminMichaelis merged 1 commit intomainfrom
bmichaelis/updateFix

Conversation

@BenjaminMichaelis
Copy link
Member

Description

Describe your changes here.

Fixes #Issue_Number (if available)

Ensure that your pull request has followed all the steps below:

  • Code compilation
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

Copilot AI review requested due to automatic review settings March 16, 2026 23:35
@BenjaminMichaelis BenjaminMichaelis self-assigned this Mar 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the INTL0101 (“Attributes on separate lines”) code fix to avoid NotImplementedException and expands test coverage so the fix works for more declaration kinds beyond classes.

Changes:

  • Generalize the code fix to operate on MemberDeclarationSyntax rather than only class/method/property/field nodes.
  • Add code-fix tests covering structs, records, interfaces, enums, constructors, enum members, and indexers.
  • Reformat/normalize Directory.Packages.props (appears to be non-semantic churn).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
IntelliTect.Analyzer/IntelliTect.Analyzer.Test/AttributesOnSeparateLinesTests.cs Adds new code-fix tests for additional declaration types (struct/record/interface/enum/etc.).
IntelliTect.Analyzer/IntelliTect.Analyzer.CodeFixes/AttributesOnSeparateLines.cs Broadens the code fix to handle more declaration syntax kinds by switching to MemberDeclarationSyntax.
Directory.Packages.props Entire file rewritten with no apparent semantic version changes (likely line-ending/format normalization).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…on types

The AttributesOnSeparateLines code fix only handled ClassDeclarationSyntax,
MethodDeclarationSyntax, PropertyDeclarationSyntax, and FieldDeclarationSyntax.
Any other declaration type flagged by the analyzer (structs, records, interfaces,
enums, constructors, enum members, indexers, etc.) would throw NotImplementedException
when a user tried to apply the code fix.

Replace the two switch expressions with a MemberDeclarationSyntax base class
pattern match in RegisterCodeFixesAsync, so unsupported node types silently
skip registering the code fix rather than crash. PutOnSeparateLine is updated
to accept MemberDeclarationSyntax directly, calling AttributeLists and
WithAttributeLists() without any helper switch methods.

Add code fix tests for: struct, record, interface, enum type, constructor,
enum member, and indexer declarations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the INTL0101 “Attributes on separate lines” code fix to avoid NotImplementedException when the diagnostic is reported on additional declaration kinds beyond the originally handled set, and expands unit test coverage accordingly.

Changes:

  • Generalize the code fix to operate on MemberDeclarationSyntax and remove the previous type-switch helpers that threw for unhandled declaration kinds.
  • Add code-fix tests for structs, records, interfaces, enums, constructors, enum members, and indexers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
IntelliTect.Analyzer/IntelliTect.Analyzer.CodeFixes/AttributesOnSeparateLines.cs Broadens the code fix to work on any MemberDeclarationSyntax and removes the prior switch/NotImplementedException path.
IntelliTect.Analyzer/IntelliTect.Analyzer.Test/AttributesOnSeparateLinesTests.cs Adds new test cases to validate the code fix for additional declaration/member types.
Comments suppressed due to low confidence (1)

IntelliTect.Analyzer/IntelliTect.Analyzer.CodeFixes/AttributesOnSeparateLines.cs:74

  • The code fix rebuilds new AttributeListSyntax instances without preserving the original AttributeList's Target (e.g., [field: ...], [method: ...]) and also recreates AttributeSyntax nodes, which can drop trivia/comments. This can change semantics for targeted attributes and may delete user comments. Preserve AttributeListSyntax.Target when splitting, and prefer reusing/copying the existing AttributeSyntax nodes (including trivia) rather than recreating them from Name/ArgumentList.
            foreach (AttributeSyntax attribute in parentDeclaration.AttributeLists.SelectMany(l => l.Attributes))
            {
                attributeLists = attributeLists.Add(
                    SyntaxFactory.AttributeList(
                        SyntaxFactory.SeparatedList(

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BenjaminMichaelis BenjaminMichaelis merged commit b1cb7cd into main Mar 16, 2026
5 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the bmichaelis/updateFix branch March 16, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants